<layout name="layout"/>

<div class="tab-div">
    <div id="tabbar-div">
        <p>
            <span class="tab-front" id="general-tab">通用信息</span>
            <span class="tab-back">商品描述</span>
            <span class="tab-back">会员价格</span>
            <span class="tab-back">商品属性</span>
            <span class="tab-back">商品相册</span>
        </p>
    </div>
    <div id="tabbody-div">
        <form enctype="multipart/form-data" action="__SELF__" method="post">
            <input type="hidden" name="id" value="<?php echo $data['id']; ?>"/>
            <table width="90%" id="general-table" class="tab_table" align="center">
                <tr>
                    <td class="label">所在品牌：</td>
                    <td>
                        <?php buildSelect('brand', 'brand_id', 'id', 'brand_name', $data['brand_id']); ?>
                    </td>
                </tr>
                <tr>
                    <td class="label">商品名称：</td>
                    <td><input type="text" name="goods_name" size="60"
                               value="<?php echo $data['goods_name']; ?>"/>
                        <span class="require-field">*</span></td>
                </tr>
                <tr>
                    <td class="label">LOGO：</td>
                    <td>
                        <?php echo showImage($data['mid_logo']) ?><br/>
                        <input  id="file" type="file" name="logo" size="60" onchange="changepic(this)"/></td>
                </tr>
                <tr>
                    <td class="label">市场售价：</td>
                    <td>
                        <input type="text" name="market_price"
                               value="<?php echo $data['market_price']; ?>" size="20"/>
                        <span class="require-field">*</span>
                    </td>
                </tr>
                <tr>
                    <td class="label">本店售价：</td>
                    <td>
                        <input type="text" name="shop_price"
                               value="<?php echo $data['shop_price']; ?>" size="20"/>
                        <span class="require-field">*</span>
                    </td>
                </tr>

                <tr>
                    <td class="label">是否上架：</td>
                    <td>
                        <input type="radio" name="is_on_sale"
                               value="是" <?php if($data['is_on_sale'] == '是') echo 'checked="checked"'; ?>
                        /> 是
                        <input type="radio" name="is_on_sale"
                               value="否" <?php if($data['is_on_sale'] == '否') echo 'checked="checked"'; ?>
                        /> 否
                    </td>
                </tr>
            </table>
            <!-- 商品描述 -->
            <table style="display:none;" width="100%" class="tab_table" align="center">
                <tr>
                    <td>
                        <textarea id="goods_desc"
                                  name="goods_desc"><?php echo $data['goods_desc']; ?></textarea>
                    </td>
                </tr>
            </table>
            <!-- 会员价格 -->
            <table style="display:none;" width="90%" class="tab_table" align="center">
                <tr>
                    <td class="label">会员价格：</td>
                    <td>
                        <?php foreach($mlData as $k=>$v): ?>
                        <?php echo $v['level_name']; ?>:¥<input type="text"
                                                                name="member_price[<?php echo $v['level_id']; ?>]"
                                                                value="<?php echo $v['price']; ?>"
                                                                size="8"/>元<br/>
                        <?php endforeach; ?>
                    </td>
                </tr>
            </table>
            <!-- 商品属性 -->
            <table style="display:none;" width="90%" class="tab_table" align="center">
                <tr>
                    <td></td>
                </tr>
            </table>
            <!-- 商品相册 -->
            <table style="display:none;" width="100%" class="tab_table" align="center">
                <tr>
                    <td>
                        <input id="btn_add_pic" type="button" value="添加一张"/>
                        <hr/>
                        <ul id="ul_pic_list"></ul>
                        <ul id="old_pic_list">
                            <?php foreach($gpData as $k => $v): ?>
                                <li>
                                    <input pic_id="<?php echo $v['id'] ;?>" class="btn_del_pic"
                                    type="button" value="删除"
                                    /><br/>
                                    <?php showImage($v['mid_pic'],150);?>
                                </li>
                            <?php endforeach; ?>
                        </ul>
                    </td>
                </tr>
            </table>
            <div class="button-div">
                <input type="submit" value=" 确定 " class="button"/>
                <input type="reset" value=" 重置 " class="button"/>
            </div>
        </form>
    </div>
</div>

<!--导入在线编辑器 -->
<link href="__PUBLIC__/umeditor1_2_2-utf8-php/themes/default/css/umeditor.css" type="text/css"
      rel="stylesheet">
<script type="text/javascript" charset="utf-8"
        src="__PUBLIC__/umeditor1_2_2-utf8-php/umeditor.config.js"></script>
<script type="text/javascript" charset="utf-8"
        src="__PUBLIC__/umeditor1_2_2-utf8-php/umeditor.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/umeditor1_2_2-utf8-php/lang/zh-cn/zh-cn.js"></script>
<script>
    UM.getEditor('goods_desc', {
        initialFrameWidth: "100%",
        initialFrameHeight: 350
    });
    /****切换的代码******/
    $("#tabbar-div p span").click(function () {
        var i = $(this).index();
        $(".tab_table").hide();
        $(".tab_table").eq(i).show();
        $(".tab-front").removeClass("tab-front").addClass("tab-back");
        $(this).removeClass("tab-back").addClass("tab-front");
    })
    // 添加一张
    $("#btn_add_pic").click(function(){
        var file = '<li><input type="file" name="pic[]" /></li>';
        $("#ul_pic_list").append(file);
    });
    function changepic() {
        var reads = new FileReader();
        f = document.getElementById('file').files[0];
        reads.readAsDataURL(f);
        reads.onload = function (e) {
            document.getElementById('show').src = this.result;
        };
    }
    $(".btn_del_pic").click(function () {
        if (confirm("确定要删除吗?")) {
            var li = $(this).parent();
            var pid = $(this).attr("pic_id");
            $.ajax({
                type : "GET",
                url  : "<?php  echo U('ajaxDelPic','',FALSE); ?>/picid/"+pid,
                success : function (data) {
                    li.remove();
                }
            });
        }
    });
</script>
























